//引入Cookie
import Cookies from 'js-cookie';

//存cookie
export const SetCookie=(name,value)=>{
    Cookies.set(name, value, { expires: 7 });
}

//取cookie
export const GetCookie=name=>Cookies.get(name);

//删cookie
export const DelCookie=name=>{
    Cookies.remove(name);
}

//存缓存 name存的名字 obj存的数据 window.localStorage.setItem(存的名字,存的数据)
// 存储数据方式
export const setStore=(name,value)=>{
    window.localStorage.setItem(name,value)
}

//取缓存 window.localStorage.getItem(获取缓存的名字)
export const getStore=name=>window.localStorage.getItem(name);

//删缓存 window.localStorage.removeItem(删除缓存的名字)
export const delStore=name=>{
    window.localStorage.removeItem(name)
}

//清除用户电脑里面的本地缓存 (退出登录) window.localStorage.clear()
export const clearStore=()=>{
    window.localStorage.clear()
}

// 浏览器会话存储数据方式
export const setSession=(name,value)=>{
    window.sessionStorage.setItem(name,value)
}

//取缓存 window.sessionStorage.getItem(获取缓存的名字)
export const getSession=name=>window.sessionStorage.getItem(name);

//删缓存 window.sessionStorage.removeItem(删除缓存的名字)
export const delSession=name=>{
    window.sessionStorage.removeItem(name)
}

//清除用户电脑里面的浏览器会话缓存 (退出登录) window.sessionStorage.clear()
export const clearSession=()=>{
    window.sessionStorage.clear()
}

//递归数组
var List = [];
export const SetArr = (arr,n)=>{
    if(n==0){
        List = []
    }
    if(arr && arr instanceof Array){
        for(let item of arr){
            SetArr(item,1)
        }
    }else{
        List.push(arr)
    }
    let List1 = [...new Set(List)];
    return List1
}